<template>
  <div>
    <div style="box-shadow: 0 0 10px rgba(0,0,0,.1);padding: 10px 20px;border-radius: 5px;margin-bottom: 10px">
      {{ user.name }},欢迎使用饮水系统
    </div>
    <div style="display: flex">
      <el-card style="width: 30%;margin-right: 10px">
        <div slot="header" class="clearfix">
          <span>页面主题色</span>
        </div>
        <div style="display: flex; justify-content: center;margin: 10px">
          <el-button type="primary" style="padding: 10px">颜色：主要</el-button>
          <el-button type="success" style="padding: 10px">颜色：成功</el-button>
          <el-button type="warning" style="padding: 10px">颜色：警告</el-button>
        </div>
        <div style="display: flex; justify-content: center">
          <el-button type="danger" style="padding: 10px">颜色：危险</el-button>
          <el-button type="info" style="padding: 10px">颜色：信息</el-button>
        </div>
      </el-card>
    </div>

    <div style="display:flex;margin: 15px 0">
      <el-card style="width: 50%">
        <div style="margin-bottom:15px;font-weight: bold;font-size: 20px">系统公告</div>
        <el-timeline>
          <el-timeline-item v-for="item in notices" :key="item.id" :timestamp="item.time" placement="top">
            <el-card>
              <h4>{{ item.title }}</h4>
              <p>{{ item.content }}</p>
            </el-card>
          </el-timeline-item>
        </el-timeline>
      </el-card>

      <el-card style="width: 50%;margin-left: 20px">
        <div style="margin-bottom:15px;font-weight: bold;font-size: 20px">系统公告</div>
        <el-collapse v-model="activeName" accordion>
          <el-collapse-item v-for="(item,index) in notices" :key="item.id" :name="index + ''">
            <template slot="title">
              <h4>{{ item.title }}</h4>
            </template>
            <div>{{ item.content }}</div>
          </el-collapse-item>
        </el-collapse>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      user: JSON.parse(localStorage.getItem('base-user') || '{}'),
      notices: [],
      activeName: '0',
    }
  },
  created() {
    this.loadNotice()
  },
  methods: {
    loadNotice() {
      this.$request.get('/notice/selectNotice').then(res => {
        this.notices = res.data
      })
    },
  }
}
</script>

<style scoped>

</style>